package day04;

import java.util.LinkedList;
import java.util.Queue;

public class P07QueueDemo {
    //Queue FIFO = First In First Out
    public static void main(String[] args) {
        Queue<Integer> Q=new LinkedList<Integer>();
        int [] a=new int[]{6,3,1,7,5,8,9,2,4};
        for(int i=0;i<a.length;i++){
            Q.offer(a[i]);
        }


        while(!Q.isEmpty()){
            System.out.print(Q.peek());
            Q.poll();
            if(Q.size()>1){
                int x=Q.peek();
                Q.poll();
                Q.offer(x);
            }
        }
    }
}
              